package com.yida.gwj.report.service.impl;

import cn.hutool.core.map.MapBuilder;
import com.yida.common.core.constant.SecurityConstants;
import com.yida.common.core.utils.PageUtils;
import com.yida.gwj.api.domain.GwjConfDictData;
import com.yida.gwj.api.service.RemoteGwjConfigService;
import com.yida.gwj.report.domain.dto.GwjBizProgressDTO;
import com.yida.gwj.report.domain.request.GwjBizProgressQueryRequest;
import com.yida.gwj.report.mapper.GwjBusinessProgressMapper;
import com.yida.gwj.report.service.IGwjBusinessProgressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author: PPV
 * @Date: 2023-02-28
 */
@Service
public class GwjBusinessProgressServiceImpl implements IGwjBusinessProgressService {

    @Resource
    private GwjBusinessProgressMapper progressMapper;

    @Resource
    private RemoteGwjConfigService remoteGwjConfigService;

    @Override
    public List<GwjBizProgressDTO> getPage(GwjBizProgressQueryRequest request) {
        //拼接业务表名
        GwjConfDictData dictData = remoteGwjConfigService.getGwjConfDictDataByDictLabel(request.getDictLabel(), SecurityConstants.INNER).getData();
        String bizTable = new StringBuilder().append("gwj_").append(dictData.getDictValue()).append("_business").toString();
        //设置分页参数
        PageUtils.startPage();
        //构造查询参数
        Map<String, Object> paramMap = MapBuilder.<String, Object>create()
                .put("bizTable", bizTable)
                .put("bizNum", request.getBizNum())
                .put("currentOperName", request.getCurrentOperName())
                .put("applicant", request.getApplicant())
                .put("bizName", request.getBizName())
                .put("applicantTime", request.getApplicantTime())
                .put("areaId", request.getAreaId())
                .build();
        return progressMapper.list(paramMap);
    }


}
